package com.appbee.gdata.picasa.server;

import javax.inject.Inject;

import com.appbee.user.server.dao.UserControl;

public class PicasaSettingsService
{
	private final PicasaUserAccount userAccount;
	private final UserControl userControl;

	@Inject
	public PicasaSettingsService(PicasaUserAccount userAccount,
			UserControl userControl)
	{
		this.userAccount = userAccount;
		this.userControl = userControl;

	}

	public String getUserName()
	{
		userControl.assertUserIsAdmin();
		userAccount.ensureLoaded();
		return userAccount.getUserName();
	}

	public void saveUserInfo(String userName, String password)
	{
		userControl.assertUserIsAdmin();
		userAccount.setUserName(userName);
		userAccount.setPassword(password);
		userAccount.save();
	}

	public void flushCache()
	{
		userControl.assertUserIsAdmin();
		userAccount.load();
	}

}
